﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;

namespace zuoye2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public ArrayList data = new ArrayList();
        float average = 0f;
        int max = 0;
        int min= 0;
        int sum = 0;
        int temp = 0;

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (data.Count == 0)
            {
                MessageBox.Show("请输入整数");

            }//防止没有值时计算

            else
            {
                max= min = (int)data[0];//初始化
                for (int i = 0; i < data.Count; i++)
                {
                    temp = (int)data[i];
                    if (((int)data[i]) >= max)
                    {
                        max = (int)data[i];

                    }
                    if ((int)data[i] < min)
                    {
                        min = (int)data[i];
                    }
                    sum = sum + temp;
                }
                
                average = (float)sum / (float)data.Count;
            }
           label6 .Text = max.ToString();
            label7.Text = min.ToString();
            label8.Text = sum.ToString();
            label9.Text = average.ToString();
            //输出运算结果
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

            if (textBox1.Text == "")
            {
                MessageBox.Show("请输入整数");
            }//避免空输入
            else
            {
                data.Add(int.Parse(textBox1.Text));
                textBox1.Clear();
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label9_Click(object sender, EventArgs e)
        {

        }
    }
}
